From 4d32d9024b384a926987b46516103d7b6b240fa2 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 15 Mar 2004 14:10:08 +0000 Subject: [PATCH] [Win32] Look up installation prefix at run-time, replace prefix in 2004-03-15 Tor Lillqvist * queryloaders.c (main): [Win32] Look up installation prefix at run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141) --- gdk-pixbuf/ChangeLog | 5 ++++- gdk-pixbuf/queryloaders.c | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 7d2a06bef8..2a20a446f5 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,7 +1,10 @@ 2004-03-15 Tor Lillqvist + * queryloaders.c (main): [Win32] Look up installation prefix at + run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141) + Merges from stable branch that had been left out. (#136282, J. Ali - Harlow) + Harlow): Changes for run-time lookup of installation location on Win32: diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c index e2f6bfc910..21aa320eb0 100644 --- a/gdk-pixbuf/queryloaders.c +++ b/gdk-pixbuf/queryloaders.c @@ -45,6 +45,10 @@ #endif #define SOEXT_LEN (strlen (SOEXT)) +#ifdef G_OS_WIN32 +#include +#endif + static void print_escaped (const char *str) { @@ -203,6 +207,45 @@ int main (int argc, char **argv) { gint i; +#ifdef G_OS_WIN32 + gchar libdir[sizeof (PIXBUF_LIBDIR) + 100]; + gchar runtime_prefix[1000]; + gchar *slash; + + strcpy (libdir, PIXBUF_LIBDIR); + + if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 && + (PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '/' || + PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '\\')) { + /* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it + * normally is. Replace that prefix in PIXBUF_LIBDIR + * with the installation directory on this machine. + * We assume this invokation of + * gdk-pixbuf-query-loaders is run from either a "bin" + * subdirectory of the installation directory, or in + * the insallation directory itself. + */ + GetModuleFileName (NULL, runtime_prefix, sizeof (runtime_prefix)); + + slash = strrchr (runtime_prefix, '\\'); + *slash = '\0'; + slash = strrchr (runtime_prefix, '\\'); + if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) { + *slash = '\0'; + } + + if (strlen (runtime_prefix) + 1 + strlen (PIXBUF_LIBDIR) - strlen (GTK_PREFIX) < sizeof (libdir)) { + strcpy (libdir, runtime_prefix); + strcat (libdir, "/"); + strcat (libdir, PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1); + } + } + +#undef PIXBUF_LIBDIR +#define PIXBUF_LIBDIR libdir + +#endif + g_printf ("# GdkPixbuf Image Loader Modules file\n" "# Automatically generated file, do not edit\n" "#\n"); -- 2.30.2